package com.mikhailenko.transportMVC.utils;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Util {
       
    public static String encode(String password){
            StringBuffer sb = new StringBuffer();
           
            try {
                MessageDigest md = MessageDigest.getInstance("MD5");
                md.update(password.getBytes());
               
                byte[] byteData = md.digest();
                   
            for (int i = 0; i < byteData.length; i++) {
                sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
            }
        
            } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return null;
            }
            
            return sb.toString();
    }

}
